
#ifndef __MEMORY
#define __MEMORY

#define __MEMORY_SIZE      32          /* Size of the RAM in MBs */
#define __MEGABYTE         1048576     /* Size of a meg in bytes */

#define __PAGE_SIZE        4096        /* bytes per page         */
#define __PAGE_TABLE_START 0x400000    /* Start of table in mem  */

#define __PT_USED          0x00000001  /* If the table is in use */
#define __PT_MTABLE        0x00000002  /* Set if the page has an */
                                       /* mtable struct.         */
#define __MT_USED          0x01        /* For when the block is  */
                                       /* being used.            */

/* Used by the malloc data table; resides above the   */
/* malloc table.                                      */

struct __mtable_entry {

  short start;
  short offset;
  char  flags;

};

/* This is a struct for holding a malloc data table.  */
/* The actual table resides above this and the __page */
/* data fields in the page.                           */

struct __mtable {

  char  *base;              /* This points the the location of the table. */
  short  len;               /* Number of entrys in the table.             */
  struct __mtable_entry *table; /* Points to right above the struct.      */

};

/* Struct representing a psuedo page, 4KBs in size.  */

struct __page {

  unsigned int  offset;            /* Offset from data segment, I.E 0x0. */
  unsigned int  flags;             /* Is this page being used right now? */
  

};

/* Now some useful fucnctions. */

void  __init_memory();
void *__do_malloc(unsigned int);
int   __do_free(void *);

#endif
